<?php

require_once('init.php');

checkAdminLogin();

if($_GET['act']=='edit') {
  $arr = array(
    'name'       => trim($_POST['name']),
    'user_email' => trim($_POST['email']),
    'user_phone' => trim($_POST['phone']),
    'user_im'    => trim($_POST['im'])
  );
  $db->query("UPDATE @_@users SET ".$db->arr_update($arr)." WHERE user_id=".$_SESSION[AUTH.'_admin']['user_id']);
  redirect("start.php");
}

$_space_total = 100*1024*1024;
$_space_used  = get_dirsize(APP_ROOT);
$_space_perc  = round($_space_used*100/$_space_total,2);
$_space_perc  = ($_space_perc > 100 ? 100 : $_space_perc);

$_space_color = '33CC66';
if($_space_perc>90) {$_space_color = 'FF3300';}
elseif($_space_perc>60) {$_space_color = 'CC3366';}

$info = $db->getOne("SELECT * FROM @_@users WHERE user_id=".$_SESSION[AUTH.'_admin']['user_id']);

?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title> start </title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
    <link rel="stylesheet" type="text/css" href="jscss/global.css" />
    <link rel="stylesheet" type="text/css" href="themes/default/style.css" />
    <script language="javascript" type="text/javascript" src="jscss/jquery.js"></script>
    <script language="javascript" type="text/javascript" src="jscss/idtabs.js"></script>    
    <script language="javascript" type="text/javascript" src="jscss/corner.js"></script>
    <script language="javascript" type="text/javascript" src="jscss/tipsy.js"></script>
    <script language="javascript" type="text/javascript" src="jscss/popup.js"></script>
    <script type="text/javascript" src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=<?php echo $_SESSION[AUTH.'_admin']['visitip'];?>"></script>
    
    <!--[if IE 6]>
    <link rel="stylesheet" type="text/css" href="themes/default/styleIE6.css" />
    <![endif]-->
  </head>
  
  <body>
  
    <div class="navTool menuborder">
      <div class="t_articles">
        <h4>welcome</h4>
        <p></p>
      </div>      
    </div>
    
    <div class="panel">      
      <div class="t" id="idPanel">
        <a href="#base">基本信息</a>        
        <a href="#user">用户信息</a>
      </div>
      <div id="base">        
        <dl>
          <dt> 主机地址： </dt>
          <dd><?php echo $_SERVER['SERVER_NAME']; ?></dd>
        </dl>
        <dl>
          <dt> 主机时间： </dt>
          <dd><?php echo date("Y-m-d H:i:s"); ?></dd>
        </dl>        
        <dl>
          <dt> 主机系统：</dt>
          <dd><?php if(PATH_SEPARATOR==':') echo 'Linux'; else echo 'Windows'; ?></dd>
        </dl>
        <dl>
          <dt> 空间占用： </dt>
          <dd>
            <div style="float:left;width:200px;height:14px;line-height:13px;margin:4px;background-color:#fff;border:1px solid #d9e0f8;overflow:hidden;">
              <div style="height:14px;width:<?php echo $_space_perc,'%'; ?>;background-color:#<?php echo $_space_color;?>;"></div>
            </div>            
            <?php echo '<b>',$_space_perc,'%</b> (', format_size($_space_used), '/', format_size($_space_total), ')'; ?>
          </dd>
        </dl>
        <dl>
          <dt> 文件路径： </dt>
          <dd><?php echo APP_ROOT; ?></dd>
        </dl>        
      </div>
      <div id="user">
        <form method="post" action="?act=edit">
        <dl>
          <dt> 系统标识： </dt>
          <dd><?php echo $_SESSION[AUTH.'_admin']['user_id']; ?></dd>
        </dl>
        <dl>
          <dt> 账号名称： </dt>
          <dd><?php echo decrypt($_SESSION[AUTH.'_admin']['user_name']); ?></dd>
        </dl>
        <dl>
          <dt> 上次登录： </dt>
          <dd><?php echo $_SESSION[AUTH.'_admin']['visitip'];?> 
            <script>document.write(remote_ip_info.country+' '+remote_ip_info.province+' '+remote_ip_info.city);</script>
          </dd>
        </dl>
        <dl>
          <dt> 登录时间： </dt>
          <dd><?php echo $_SESSION[AUTH.'_admin']['lastvisit']; ?></dd>
        </dl>
        <dl>
          <dt> 用户姓名： </dt>
          <dd><input type="text" name="name" value="<?php echo $info['name'];?>" /></dd>
        </dl>
        <dl>
          <dt> 电子邮件： </dt>
          <dd><input type="text" name="email" value="<?php echo $info['user_email'];?>" /></dd>
        </dl>
        <dl>
          <dt> 联系电话： </dt>
          <dd><input type="text" name="phone" value="<?php echo $info['user_phone'];?>" /></dd>
        </dl>
        <dl>
          <dt> 即 时 通： </dt>
          <dd><input type="text" name="im" value="<?php echo $info['user_im'];?>" /></dd>
        </dl>
        <dl><dt></dt>
          <dd><input type="submit" value="提交修改" class="btn" /></dd>
        </dl>
        </form>
      </div>
    </div>
    <script>
      $(document).ready(function(){
        $("#idPanel").idTabs("base");
      });
    </script>
    
  </body>
  
</html>
